package voxelTest;

import java.util.Random;

//truly random point
public class Point {
	private int x;
	private int y;
	private int startDir;
	private int dir;
	private int dirListIndex = 0;
	private int[] dirList = new int[4];
	private static int[] permSet = {0,1,2,3,
									0,1,3,2,
									0,2,1,3,
									0,2,3,1,
									0,3,1,2,
									0,3,2,1,
									1,0,2,3,
									1,0,3,2,
									1,2,0,3,
									1,2,3,0,
									1,3,0,2,
									1,3,2,0,
									2,0,1,3,
									2,0,3,1,
									2,1,0,3,
									2,1,3,0,
									2,3,0,1,
									2,3,1,0,
									3,0,1,2,
									3,0,2,1,
									3,1,0,2,
									3,1,2,0,
									3,2,0,1,
									3,2,1,0};
	
	public Point(int x, int y, Random rnd) {
		this.x = x;
		this.y = y;
		int perm;
		
		if (GC.USE_CUSTOM_CADENCE) {
			double prob = rnd.nextDouble()*GC.TOTAL_CADENCE;
			perm = rnd.nextInt(6);
			if (prob < GC.CADENCE[0]) {
				perm += 0;
			} else if (prob < GC.CADENCE[1] + GC.CADENCE[0]) {
				perm += 6;
			} else if (prob < GC.CADENCE[2] + GC.CADENCE[1] + GC.CADENCE[0]) {
				perm += 12;
			} else { //LEFT CADENCE
				perm += 18;
			}
			perm *= 4;
		} else {
			perm = rnd.nextInt(24) *4;
		}

		this.dirList[0] = permSet[perm];
		this.dirList[1] = permSet[perm+1];
		this.dirList[2] = permSet[perm+2];
		this.dirList[3] = permSet[perm+3];
		this.startDir = dirList[0];
		this.dir = dirList[0];
	}
	
	public int getX() {
		return this.x;
	}
	public int getY() {
		return this.y;
	}
	public int getDir() {
		return this.dir;
	}
	public int getStartDir() {
		return this.startDir;
	}

	public int nextDir() {
		this.dirListIndex++;
		return this.dir = this.dirList[dirListIndex%4];
	}
}

/*
 * package mazeBueno2;

public class Point {
	private int x;
	private int y;
	private int startDir;
	private int dir;
	
	public Point(int x, int y,int startDir) {
		this.x = x;
		this.y = y;
		this.startDir = startDir;
		this.dir = startDir;
	}
	
	public int getX() {
		return this.x;
	}
	public int getY() {
		return this.y;
	}
	public int getDir() {
		return this.dir;
	}
	public int getStartDir() {
		return this.startDir;
	}

	public int nextDir() {
		this.dir = (this.dir+3)%4;
		return this.dir;
	}
	
}*/
